<script>
	export default {
		globalData: {
			height: 0,
			isLogin: false,
			header: {
				xip: ''
			}
		},
		onLaunch: function() {
			this.getPagesHeight()
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		},
		methods: {
			
			watch: function(key, method,config) {
				var obj = this.globalData;
				//加个前缀生成隐藏变量，防止死循环发生
				getApp().globalData[key + 'tmp'] = obj[key]; //obj[key]这个不能放在Object.defineProperty里
				if (getApp().globalData[key + 'tmp']) { //处理已经声明的变量，绑定处理
					method(getApp().globalData[key + 'tmp']);
				}
				Object.defineProperty(obj, key, {
					configurable: true,
					enumerable: true,
					set: function(value) {
						// console.log(value,typeof value,'值')
						getApp().globalData[key + 'tmp'] = value;
						method(value);
					},
					get: function() {
						return getApp().globalData[key + 'tmp']
					}
				})
				if (config && config.immediate) {
					// console.log('立刻执行')
					// console.log(getApp().globalData[key],'立即监听')
				}
			},
			
			getPagesHeight() {
				let that = this;
				uni.getSystemInfo({
					success: function(res) {
						let pxToRpxScale = 750 / res.windowWidth;
						that.globalData.height = res.windowHeight * pxToRpxScale;
					}
				});
				console.log(this.globalData.height, '页面高度')
			}
		}
	}
</script>

<style lang="scss">
	/*每个页面公共css */
/* @import "cl-uni/index.scss"; */
@import "@/uni_modules/uview-ui/index.scss";
@import "colorui/main.css";
@import "colorui/icon.css";
@import url("./static/style/qiun.css");
@import  "./static/icon/iconfont.css"
</style>
